//
//  BuzzerController.h
//  QuizMaster
//
//  Created by Jeppe Nielsen on 3/24/15.
//  Copyright (c) 2015 Jeppe Nielsen. All rights reserved.
//

#pragma once
#include <string>
#include <map>
#include <vector>
#include "Event.hpp"
#include "BigButtonManager.hpp"

using namespace Nano;

class BuzzerDevice {
public:

    BuzzerDevice();
    ~BuzzerDevice();

    void Bind(BigButtonManager* input);
    void Unbind();

    void Update(float dt);
    void AddBuzzer(int playerIndex, int buzzerIndex);
    
    void AllowAll();
    void DisableBuzzer(int playerIndex);
    
    Nano::Event<int> OnBuzz;
    
private:
    
    struct Buzzer {
        int index;
        bool enabled;
    };

    typedef std::map<int, Buzzer> Buzzers;
    Buzzers buzzers;
    
    int frameCounter;
    typedef std::vector<int> BuzzersDown;
    BuzzersDown buzzersThisFrame;
    
    BigButtonManager* input;
    
    void ButtonDown(BigButtonEvent e);
    
};